<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>登录</title>
		<link  rel="stylesheet" href="css/index.css" type="text/css" />
		<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
		<style>
			
			body{
				background-image: url(../img/dog.jpg);
			}
			div{
				position: relative;
			}
			form{
				position: absolute;
				border: 2px solid #FFB6C1;
				padding: 30px;
				border-radius: 5px;
				top: 200px;
				right: 200px;
			}
			form input,b{
				 margin: 5px;
				 height: 20px;
				 line-height: 20px;
				 vertical-align: middle;
			}
		</style>
	</head>
	<body>
		 <h1>华清远见班级管理系统</h1>
		 <hr>
		 <div>
			 <form action="#" method="get">
						<input type="text" name="username" placeholder="输入用户名" /><br>
			 			<input type="password" name="pwd" placeholder="请输入密码"  /><br>
			 			<input type="checkbox" value=""><b>记住密码?</b><br>
			 			<input type="submit" id="login" value="登录" />
						<input type="reset" value="登录" />
			 </form>
		 </div>
	</body>
	<script>
	    $("#login").click(function(){
	    	// 发请求
	    	$.ajax({
	    		url:"../login.do",
	    		type:"get",
	    		dataType:"json",
	    		data:$("form").serialize(),
	    		success:function(data){
	    			// JSON.parse(data) -- 将string 转换为json object;
	    			//data = JSON.parse(data);
	    			console.log(data)
	    			if(data.msg){
	    				// ① 将登录成功相关信息，存在localstorage中
	    				window.localStorage.setItem("ssm_username", $("input").eq(0).val());
	    				window.localStorage.setItem("flag","login_success");
	    				window.localStorage.setItem("token", data.token)
	    				// ② 登录成功之后， addSchool.html页面
	    				window.location.href="addSchool.html";
	    			}else{
	    				console.log("fail")
	    			}
	    		}
	    	})
	    	return false;
	    })
	</script>
</html>